local blaze = require "blaze"
local game = require "club.threecard.hbsl"
local const = game.util.const

local M = game.ui.element()

local function update_tip(self, state)
    if state.phase_id == const.PHASE_IDLE then
        self.tip_txt.text = string.format("空闲")
    end

    if state.phase_id == const.PHASE_GRAB then
        self.tip_txt.text = string.format("抢红包 %s", state.countdown)
    end

    if state.phase_id == const.PHASE_REVEAL then
        self.tip_txt.text = string.format("展示结果 %s", state.countdown)
    end

    if state.phase_id == const.PHASE_SETTLE then
        self.tip_txt.text = string.format("结算 %s", state.countdown)
    end
end

M.store_watchers = {
    gameplay = {
        ["$"] = blaze.noop,
        
        ["阶段变更"] = function(self, store, state, args)
            update_tip(self, state)
        end, 

        ["countdown变更"] = function(self, store, state, args)
            update_tip(self, state)
        end
    }
}

function M:ctor()
    self.res = "club.threecard.hbsl/ui/ingame.b:phase_shower"
end

return M